import { getPublicPostCommentContext } from "#server/service/posts"; import { listCommentsPayload } from "#server/service/post-comments"; export default defineEventHandler(async (event) => { const publicSlug = event.context.params?.publicSlug; const postSlug = event.context.params?.postSlug; if (!publicSlug || !postSlug || typeof publicSlug !== "string" || typeof postSlug !== "string") { throw createError({ statusCode: 400, statusMessage: "无效请求" }); } const ctx = await getPublicPostCommentContext(publicSlug, postSlug); if (!ctx) { throw createError({ statusCode: 404, statusMessage: "未找到" }); } const viewer = await event.context.auth.getCurrent(); const data = await listCommentsPayload(ctx.id, ctx.userId, viewer?.id ?? null); return R.success(data); });